#include "ET++.ph"
#ifdef __GNUG__
#pragma implementation
#endif

#include "ClipBoard.h"

#include "Class.h"
#include "View.h"
#include "WindowSystem.h"
#include "Data.h"

//---- ClipBoard ---------------------------------------------------------------

NewMetaImpl(ClipBoard,Object, (TP(data)));

ClipBoard::ClipBoard()
{
	data= 0;
}

ClipBoard::~ClipBoard()
{
	SafeDelete(data);
}

void ClipBoard::SetData(Data *d)
{
	SafeDelete(data);
	data= d;
}

bool ClipBoard::CanPaste(View *v)
{
	gWindowSystem->DevCheckSelection();
	if (v && data && v->CanPaste(data))
		return TRUE;
	return FALSE;
}

void ClipBoard::SelectionToClipboard(Object *op, bool makecopy)
{
	if (makecopy && op)
		op= op->DeepClone();
	if (op) {
		SetData(new ObjectData(op));
		gWindowSystem->DevHaveSelection(data);
	}
}

Command *ClipBoard::PasteClipboard(View *v)
{
	if (v && data)
		return v->PasteData(data);
	return gNoChanges;
}

